/**
 * This is a generated class and is not intended for modfication.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - Vendor.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.events.PropertyChangeEvent;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_Vendor extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void 
    {
    }   
     
    model_internal static function initRemoteClassAliasAllRelated() : void 
    {
    }

	model_internal var _dminternal_model : _VendorEntityMetadata;

	/**
	 * properties
	 */
	private var _internal_nombre : String;
	private var _internal_rut : String;
	private var _internal_fono : String;
	private var _internal_direccion : String;
	private var _internal_ciudad : String;
	private var _internal_pais : String;
	private var _internal_codigoPostal : String;
	private var _internal_contacto : String;
	private var _internal_email : String;

    private static var emptyArray:Array = new Array();

    /**
     * derived property cache initialization
     */  
    model_internal var _cacheInitialized_isValid:Boolean = false;   
    
	model_internal var _changeWatcherArray:Array = new Array();   

	public function _Super_Vendor() 
	{	
		_model = new _VendorEntityMetadata(this);
	
		// Bind to own data properties for cache invalidation triggering  
       
	}

    /**
     * data property getters
     */
	[Bindable(event="propertyChange")] 
    public function get nombre() : String    
    {
            return _internal_nombre;
    }    
	[Bindable(event="propertyChange")] 
    public function get rut() : String    
    {
            return _internal_rut;
    }    
	[Bindable(event="propertyChange")] 
    public function get fono() : String    
    {
            return _internal_fono;
    }    
	[Bindable(event="propertyChange")] 
    public function get direccion() : String    
    {
            return _internal_direccion;
    }    
	[Bindable(event="propertyChange")] 
    public function get ciudad() : String    
    {
            return _internal_ciudad;
    }    
	[Bindable(event="propertyChange")] 
    public function get pais() : String    
    {
            return _internal_pais;
    }    
	[Bindable(event="propertyChange")] 
    public function get codigoPostal() : String    
    {
            return _internal_codigoPostal;
    }    
	[Bindable(event="propertyChange")] 
    public function get contacto() : String    
    {
            return _internal_contacto;
    }    
	[Bindable(event="propertyChange")] 
    public function get email() : String    
    {
            return _internal_email;
    }    

    /**
     * data property setters
     */      
    public function set nombre(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:String = _internal_nombre;               
        if (oldValue !== value)
        {
            _internal_nombre = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "nombre", oldValue, _internal_nombre));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set rut(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_rut == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_rut;               
        if (oldValue !== value)
        {
            _internal_rut = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "rut", oldValue, _internal_rut));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set fono(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_fono == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_fono;               
        if (oldValue !== value)
        {
            _internal_fono = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "fono", oldValue, _internal_fono));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set direccion(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_direccion == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_direccion;               
        if (oldValue !== value)
        {
            _internal_direccion = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "direccion", oldValue, _internal_direccion));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set ciudad(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_ciudad == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_ciudad;               
        if (oldValue !== value)
        {
            _internal_ciudad = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "ciudad", oldValue, _internal_ciudad));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set pais(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_pais == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_pais;               
        if (oldValue !== value)
        {
            _internal_pais = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "pais", oldValue, _internal_pais));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set codigoPostal(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_codigoPostal == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_codigoPostal;               
        if (oldValue !== value)
        {
            _internal_codigoPostal = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "codigoPostal", oldValue, _internal_codigoPostal));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set contacto(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_contacto == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_contacto;               
        if (oldValue !== value)
        {
            _internal_contacto = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "contacto", oldValue, _internal_contacto));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set email(value:String) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_email == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:String = _internal_email;               
        if (oldValue !== value)
        {
            _internal_email = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "email", oldValue, _internal_email));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    

    /**
     * data property setter listeners
     */   

   model_internal function setterListenerAnyConstraint(value:flash.events.Event):void
   {
        if (model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }        
   }   

    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();    
        var validationFailureMessages:Array = new Array();    

		if (_model.isRutAvailable && _internal_rut == null)
		{
			violatedConsts.push("rutIsRequired");
			validationFailureMessages.push("rut is required");
		}
		if (_model.isFonoAvailable && _internal_fono == null)
		{
			violatedConsts.push("fonoIsRequired");
			validationFailureMessages.push("fono is required");
		}
		if (_model.isDireccionAvailable && _internal_direccion == null)
		{
			violatedConsts.push("direccionIsRequired");
			validationFailureMessages.push("direccion is required");
		}
		if (_model.isCiudadAvailable && _internal_ciudad == null)
		{
			violatedConsts.push("ciudadIsRequired");
			validationFailureMessages.push("ciudad is required");
		}
		if (_model.isPaisAvailable && _internal_pais == null)
		{
			violatedConsts.push("paisIsRequired");
			validationFailureMessages.push("pais is required");
		}
		if (_model.isCodigoPostalAvailable && _internal_codigoPostal == null)
		{
			violatedConsts.push("codigoPostalIsRequired");
			validationFailureMessages.push("codigoPostal is required");
		}
		if (_model.isContactoAvailable && _internal_contacto == null)
		{
			violatedConsts.push("contactoIsRequired");
			validationFailureMessages.push("contacto is required");
		}
		if (_model.isEmailAvailable && _internal_email == null)
		{
			violatedConsts.push("emailIsRequired");
			validationFailureMessages.push("email is required");
		}

		var styleValidity:Boolean = true;
	
	
	
	
	
	
	
	
	
    
        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && styleValidity;
    }  

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
       	var oldValue:Boolean = model_internal::_isValid;               
        if (oldValue !== value)
        {
        	model_internal::_isValid = value;
        	_model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }        
    }

    /**
     * derived property getters
     */

    [Transient] 
	[Bindable(event="propertyChange")] 
    public function get _model() : _VendorEntityMetadata
    {
		return model_internal::_dminternal_model;              
    }	
    
    public function set _model(value : _VendorEntityMetadata) : void       
    {
    	var oldValue : _VendorEntityMetadata = model_internal::_dminternal_model;               
        if (oldValue !== value)
        {
        	model_internal::_dminternal_model = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }     
    }      

    /**
     * methods
     */  


    /**
     *  services
     */                  
     private var _managingService:com.adobe.fiber.services.IFiberManagingService;
    
     public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
     {
         _managingService = managingService;
     }                      
     
    model_internal function set invalidConstraints_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_invalidConstraints;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;   
			_model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);   
        }     	             
    }             
    
     model_internal function set validationFailureMessages_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_validationFailureMessages;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;   
			_model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);   
        }     	             
    }        
     
     // Individual isAvailable functions     
	// fields, getters, and setters for primitive representations of complex id properties

}

}
